@extends('layouts.app')

@section('title', $article->title)
@section('description', $article->excerpt)

@section('content')
    <div class="row mb-5">
        <div class="col-lg-9 col-md-9 ">
            <div class="whitebg">
                <h2 class="htitle"><span class="con_nav">您现在的位置是：
                    <a href="/">网站首页</a>><a href="{{ route('articles.index') }}">个人博客</a></span>博客详情
                </h2>

                <h1 class="con_tilte">{{ $article->title }}</h1>
                <p class="bloginfo">
                    <i class="avatar">
                            <img alter="{{ $article->user->name }}" src="{{ $article->user->getAvatar() }}">
                    </i>
                    <span>{{ $article->user->name }}</span>
                    <span>2018-10-28</span>
                    <span>【<a
                                href="{{ route('categories.show',$article->category->id) }}">{{ $article->category->name }}</a>】</span><span>{{ $article->view_count }}
                        人已围观
                    </span>
                    <span>{{ $article->created_at->diffForHumans() }}</span>
                    <i class="far fa-comment"></i>
                    {{ $article->reply_count }}
                </p>
                <p class="con_info"><b>摘要</b>{{ $article->excerpt }}
                </p>
                <div class="con_text ">
                    <div class="article-body mt-4 mb-4">
                        {!! $article->body !!}
                    </div>
                    @if(count($article->tags)>=1)
                    <p>Tags：
                        @foreach($article->tags as $tag)
                        <a href="{{ route('tags.show',$tag->id) }}" target="_blank">{{ $tag->name }}</a> &nbsp;
                        @endforeach
                    <p class="share"><b>转载：</b>非常欢迎各位朋友分享到个人站长或者朋友圈，转载请说明文章出处“来源maxotm.cn”。</p>
                        @else
                        <p>
                        <p class="share"><b>转载：</b>非常欢迎各位朋友分享到个人站长或者朋友圈，转载请说明文章出处“来源maxotm.cn”。 </p>
                    @endif
                    <p><top :article_id="{{$article->id}}"></top></p>
                    <div class="nextinfo">
                        @if(!empty($prev_article))
                            <p>
                                上一篇：<a href="{{ route('articles.show',$prev_article->id) }}">{{ $prev_article->title }}</a>
                            </p>
                        @else
                            <p>上一篇：没有上一篇了~</p>
                        @endif
                        @if(!empty($next_article))
                            <p>
                                下一篇：<a href="{{ route('articles.show',$next_article->id) }}">{{ $next_article->title }}</a>
                            </p>
                        @else
                            <p>下一篇：没有下一篇了~</p>
                        @endif
                    </div>
                </div>
                @can('manage_contents')
                <div class="operate">
                    <hr>
                    <a href="{{ route('articles.edit', $article->id) }}" class="btn btn-outline-secondary btn-sm" role="button">
                        <i class="far fa-edit"></i> 编辑
                    </a>
                    <form action="{{ route('articles.destroy', $article->id) }}" method="post"
                          style="display: inline-block;"
                          onsubmit="return confirm('您确定要删除吗？');">
                        {{ csrf_field() }}
                        {{ method_field('DELETE') }}
                        <button type="submit" class="btn btn-outline-secondary btn-sm">
                            <i class="far fa-trash-alt"></i> 删除
                        </button>
                    </form>
                </div>
                    @endcan
            </div>

            <div class="whitebg">
                <h2 class="htitle">相关文章</h2>
                <ul class="otherlink">
                    @foreach($articles as $art)
                    <li><a href="{{ $art->link() }}" title="{{ $art->title }}">{{ $art->title }}</a></li>
                  @endforeach
                </ul>
            </div>

            <div class="whitebg gbook card">
                <h2 class="htitle">文章评论</h2>
                <ul>
                    <div class="fb">
                        @includeWhen(Auth::check(),'articles._reply_box', ['article' => $article])
                        @include('articles._reply_list', ['replies' => $article->replies()->with('user')->orderBy('id','desc')->get()])
                    </div>
                </ul>
            </div>
        </div>

        <div class="col-lg-3 col-md-3 sidebar">
            @include('layouts._sidebar')
        </div>
    </div>
    <a id="scrollUp" href="#top" style="position: fixed; z-index: 2147483647;">Scroll to top</a>
    </div>
@stop
@section('styles')
    <link rel="stylesheet" href="{{ asset('css/article.css') }}">
@stop